package com.douqu.game.main.server.entity;

import com.douqu.game.core.config.card.CardConfig;
import com.douqu.game.core.entity.GameObject;
import com.douqu.game.core.factory.DataFactory;
import com.douqu.game.core.protobuf.SGCommonProto;
import com.douqu.game.core.protobuf.SGMainProto;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2018-02-02 19:00
 */
public class PlayerGoodsChange {

    private String createTime;

    private String playerIndex;

    private String playerName;

    private int code;

    private int goodsType;

    private int id;

    private int count;

    private int after;

    private String remark;

    private String option;


    public PlayerGoodsChange(String createTime, String playerIndex, String playerName, int code, int goodsType, int id, int count, int after)
    {
        this.createTime = createTime;
        this.playerIndex = playerIndex;
        this.playerName = playerName;
        this.code = code;
        this.id = id;
        this.count = count;
        this.goodsType = goodsType;
        this.after = after;

        GameObject gameObject = null;

        StringBuilder buffer = new StringBuilder();
        buffer.append("操作->");
        buffer.append(SGMainProto.E_MSG_ID.forNumber(code));
        buffer.append(",");

        if(count < 0)
            buffer.append("消耗->");
        else
            buffer.append("获得->");

        if(goodsType == SGCommonProto.E_GOODS_TYPE.GOODS_TYPE_PROPS_VALUE)
        {
            gameObject = DataFactory.getInstance().getGameObject(DataFactory.PROP_KEY, id);
            buffer.append("道具->");
        }
        else if(goodsType == SGCommonProto.E_GOODS_TYPE.GOODS_TYPE_ASSETS_VALUE)
        {
            gameObject = DataFactory.getInstance().getGameObject(DataFactory.ASSET_KEY, id);
            buffer.append("资源->");
        }
        else if(goodsType == SGCommonProto.E_GOODS_TYPE.GOODS_TYPE_CARDS_VALUE)
        {
            gameObject = DataFactory.getInstance().getGameObject(DataFactory.CARD_KEY, id);
            buffer.append("卡牌->");
        }
        if(gameObject != null)
        {
            buffer.append(gameObject.name);
            buffer.append("x");
            buffer.append(count);
            buffer.append(",现在数量->");
            buffer.append(after);
            if(count == 0 && gameObject instanceof CardConfig)
            {
                buffer.append("(已经拥有此卡牌,转化为碎片,此条记录只是用来做展示用,没有实际获得物品)");
            }
        }

        this.remark = buffer.toString();
    }


    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getPlayerIndex() {
        return playerIndex;
    }

    public void setPlayerIndex(String playerIndex) {
        this.playerIndex = playerIndex;
    }

    public String getPlayerName() {
        return playerName;
    }

    public void setPlayerName(String playerName) {
        this.playerName = playerName;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public int getAfter() {
        return after;
    }

    public void setAfter(int after) {
        this.after = after;
    }

    public int getGoodsType() {
        return goodsType;
    }

    public void setGoodsType(int goodsType) {
        this.goodsType = goodsType;
    }

    public String getOption() {
        return option;
    }

    public void setOption(String option) {
        this.option = option;
    }


}
